<template>
  <aside class="sidebar">
    <div class="sidebar-header">
      <div class="logo">
        <i class="fa fa-database"></i>
        <span>数据解析平台</span>
      </div>
    </div>

    <nav class="sidebar-menu">
      <ul>
        <li v-for="item in menuItems" :key="item.name" :class="{ active: currentRoute === item.name }">
          <router-link :to="item.path">
            <i :class="item.icon"></i>
            <span>{{ item.label }}</span>
          </router-link>
        </li>
      </ul>
    </nav>
  </aside>
</template>

<script setup>
import {computed} from 'vue';
import { useRoute } from 'vue-router';

const route = useRoute();

// 侧边栏菜单项
const menuItems = [
  { name: 'home', path: '/general-page', label: '首页', icon: 'fa fa-home' },
  { name: 'upload', path: '/upload-page', label: '上传文件', icon: 'fa fa-upload' },
  { name: 'analysis', path: '/analysis', label: '数据分析', icon: 'fa fa-chart-line' },
  { name: 'comparison', path: '/comparison', label: '数据对比', icon: 'fa fa-exchange-alt' },
  { name: 'visualization', path: '/visualization', label: '数据可视化', icon: 'fa fa-project-diagram' }
];

// 当前激活的路由
const currentRoute = computed(() => {
  const pathMap = {
    '/general-page':'home',
    '/upload-page': 'upload',
    '/analysis': 'analysis',
    '/comparison': 'comparison',
    '/visualization': 'visualization'
  };
  return pathMap[route.path] || '';
});
</script>

<style scoped>
.sidebar {
  position: fixed;
  top: 20%;
  left: 0px;
  height: 80vh;
  width:11.5%;
  background-color: transparent;
  color: white;
  z-index: 2;
  overflow-y: auto;
  transition: width 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
}

.sidebar-menu {
  padding: 10px 0;
}

.sidebar-menu ul {
  list-style: none;
}


.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 0px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: all 0.3s;
}

.sidebar-menu li a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar-menu li.active a {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  border-left: 3px solid #165DFF;
}
</style>